//
//  ShareData.swift
//  focusOn
//
//  Created by 恒 on 2025/7/17.
//

import Foundation
import WidgetKit
struct SharedDataStore {
    private static let appGroup = "group.com.focusOn.timer"
    private static let sharedKey = "sharedTextData"
    private static let solidTimeSecondKey = "solidTimeSecond"
        
    static var solidTimeSecond: Double {
        get {
            return UserDefaults(suiteName: appGroup)?.double(forKey: solidTimeSecondKey) ?? 0.0
        }
        set {
            UserDefaults(suiteName: appGroup)?.set(newValue, forKey: solidTimeSecondKey)
            WidgetCenter.shared.reloadAllTimelines() // 通知小组件刷新
        }
    }
    
    static var sharedDouble: Double {
        get {
            return UserDefaults(suiteName: appGroup)?.double(forKey: sharedKey) ?? 0.0
        }
        set {
            UserDefaults(suiteName: appGroup)?.set(newValue, forKey: sharedKey)
            WidgetCenter.shared.reloadAllTimelines() // 通知小组件刷新
        }
    }
}
